Add JsonImport resource for bulk data import (PIP-310)#137
Merged
Conversation
- DataSource.import_json: POST /data_sources/{uuid}/json_imports
- DataSource.import_status: GET /data_sources/{uuid}/json_imports/{import_id}
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace monkey-patched DataSource.import_json/import_status with a dedicated JsonImport class that has its own schema, so response fields (id, external_id, status, status_details) are properly deserialized instead of being silently dropped by DataSource's EXCLUDE schema. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bd13501 to
7f3d54e
Compare
mynameispedro
approved these changes
Apr 14, 2026
loomchild
approved these changes
Apr 14, 2026
|
|
||
|
|
||
| JsonImport.create = JsonImport._method( | ||
| "create", "post", "/data_sources{/uuid}/json_imports") |
There was a problem hiding this comment.
[minor] IMO param should be called data_source_uuid. import_id should be passed as id or perhaps even uuid (but then inconsistent with field name, not sure what we do in other resources in such case; it also doesn't have a prefix, not sure if it's because it's not an independent object.).
Contributor
Author
There was a problem hiding this comment.
For me it is obvious that if uuid path param is under /data_sources/{uuid} then it is the DataSource's UUID, but being explicit won't hurt, I updated it to data_source_uuid 👍 .
I like the import_id to id update, I don't want to use uuid because the id is what Import Data in Bulk responds with:
Address review feedback from loomchild: use data_source_uuid consistently with the rest of the SDK, and id for the import identifier. Add custom _validate_arguments for both params. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
loomchild
approved these changes
Apr 15, 2026
loomchild
left a comment
There was a problem hiding this comment.
LGTM and works for me, thanks for the changes.
mynameispedro
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JsonImportresource class with dedicated schema for bulk import API responsesJsonImport.create(config, uuid='ds_...', data={...}): POST/data_sources/{uuid}/json_importsJsonImport.retrieve(config, uuid='ds_...', import_id='...'): GET/data_sources/{uuid}/json_imports/{import_id}Usage
Backwards compatibility
JsonImportresource classJsonImport.createmethodJsonImport.retrievemethodTest plan
JsonImport.createwith realistic bulk import payload (customers, plans, invoices, line items, transactions, subscription events)JsonImport.retrievewith status response assertions🤖 Generated with Claude Code